﻿using System;

using Moe.ECamel.Common.Entities;
using Moe.ECamel.Client.Controllers;
using Moe.ECamel.Client.WinForms.Common;

namespace Moe.ECamel.Client.WinForms.Controls
{
	public partial class EmployeeDetailsControl : ECamelUserControl
	{
		public EmployeeDetailsControl()
		{
			InitializeComponent();
		}

		private DetailsMode _detailsMode;
		public DetailsMode DetailsMode
		{
			get { return _detailsMode; }
			set
			{
				this._detailsMode = value;
				this.SalaryNumericUpDown.Enabled = (value != DetailsMode.View);
				this.UserDetailsControl.DetailsMode = value;
			}
		}

		public void Bind(Employee entity)
		{
			this.EmployeeBindingSource.DataSource = entity;
			SalaryNumericUpDown.Bind(EmployeeBindingSource, "Salary");

			UserDetailsControl.Bind(entity.User);
		}
		public void CancelEdit()
		{
			this.EmployeeBindingSource.CancelEdit();
			this.UserDetailsControl.CancelEdit();
		}
	}
}